<?php
/**
 * com_Easiv3
 * 
 * @author Lukas Gruber
 * @copyright 2012, Lukas Gruber
 * @license GNU/GPLv3 - http://www.gnu.org/licenses/gpl-3.0.html
 * @contact lukasgruber@gmx.net
 * @website http://www.lukasg255.bplaced.net
 */

defined('_JEXEC') or die();

jimport('joomla.application.component.controller');
require_once JPATH_COMPONENT.DS.'helpers'.DS.'extensionshelper.php';

class Easiv3ControllerManageExtensions extends JController {
	
	var $extensionHelper;
	
	function gotoInstances() {
		JRequest::setVar('view', 'manageInstances');
		
		parent::display();
	}
	
	/**
	 * Controllerfunction for install task. Proxy to extensionsHelper->install()
	 */
	function install() {
		$this->extensionHelper = new ExtensionsHelper('repository');

		$selectedItems = JRequest::getVar('selected');
				
		$this->extensionHelper->setSelectedPackages($selectedItems);
		
		$this->extensionHelper->install();
		
		JRequest::setVar('view', 'manageExtensions');
		
		parent::display();
	}
	
	/**
	 * Controllerfunction for uninstall task. Proxy to extensionsHelper->uninstall()
	 */
	function uninstall() {
		$this->extensionHelper = new ExtensionsHelper('repository');

		$selectedItems = JRequest::getVar('selected');
				
		$this->extensionHelper->setSelectedPackages($selectedItems);
		
		$this->extensionHelper->uninstall();
		
		JRequest::setVar('view', 'manageExtensions');
		
		parent::display();
	}
}